/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplemetrosystem.model.Command.EditCommand;

import java.util.ArrayList;
import simplemetrosystem.control.ElementManager;
import simplemetrosystem.model.Command.Command;
import simplemetrosystem.model.Element.MetroStation;
import simplemetrosystem.model.Element.MetroEdge;

/**
 *
 * @author Eric Qian
 */
public class RemoveStationCommand implements Command {

    /**
     * 
     * @param station 
     */
    public RemoveStationCommand(MetroStation station) {
        this.station = station;
        edges = ElementManager.getInstance().getEdgesOfStation(station);
    }

    public void execute() {
        ElementManager.getInstance().removeStation(station);
    }

    public void undo() {
        ElementManager elementManager = ElementManager.getInstance();
        elementManager.addStation(station);
        for (int i = 0; i < edges.size(); i++) {
            elementManager.addEdge(edges.get(i));
        }
    }
    private MetroStation station;
    private ArrayList<MetroEdge> edges;
}
